/********************************************************************************
  * @file    displaydriver.h
  * @author  MX
  * @version V1.5.0
  * @date    2-July-2017
  * @brief   MXGUI display driver Header File.
  *
  * 1.  This file provides two functions and one global variable to be called from
  *     user application:
  *      - SystemInit(): Setups the system clock (System clock source, PLL Multiplier
  *                      factors, AHB/APBx prescalers and Flash settings).
  *                      This function is called at startup just after reset and
  *                      before branch to main program. This call is made inside
  *                      the "startup_stm32f10x_xx.s" file.
  *
  *      - SystemCoreClock variable: Contains the core clock (HCLK), it can be used
  *                                  by the user application to setup the SysTick
  *                                  timer or configure other parameters.
  *
  *      - SystemCoreClockUpdate(): Updates the variable SystemCoreClock and must
  *                                 be called whenever the core clock is changed
  *                                 during program execution.
  *
  ******************************************************************************
  * @attention
  *
  * THE PRESENT FIRMWARE WHICH IS FOR GUIDANCE ONLY AIMS AT PROVIDING CUSTOMERS
  * WITH CODING INFORMATION REGARDING THEIR PRODUCTS IN ORDER FOR THEM TO SAVE
  * TIME. AS A RESULT, STMICROELECTRONICS SHALL NOT BE HELD LIABLE FOR ANY
  * DIRECT, INDIRECT OR CONSEQUENTIAL DAMAGES WITH RESPECT TO ANY CLAIMS ARISING
  * FROM THE CONTENT OF SUCH FIRMWARE AND/OR THE USE MADE BY CUSTOMERS OF THE
  * CODING INFORMATION CONTAINED HEREIN IN CONNECTION WITH THEIR PRODUCTS.
  *
  * <h2><center>&copy; COPYRIGHT 2017 MX Team</center></h2>
  ******************************************************************************
  */
#ifndef __DISPLAYDRIVER_H__
#define __DISPLAYDRIVER_H__

/*********************************************************************
* Macros: RGB565CONVERT(red, green, blue)
*
* Overview: Converts true color into 5:6:5 RGB format.
*
* PreCondition: none
*
* Input: Red, Green, Blue components.
*
* Output: 5 bits red, 6 bits green, 5 bits blue color.
*
* Side Effects: none
*
********************************************************************/
/********************************************************************
  * @brief  Converts true color into 5:6:5 RGB format.
  * @param  Red, Green, Blue components.
  *   
  * @retval None
********************************************************************/
#define RGB565CONVERT(red, green, blue) (WORD) (((red >> 3) << 11) | ((green >> 2) << 5) | (blue >> 3))

/*********************************************************************
* Overview: Some basic colors definitions.
*********************************************************************/
#define BLACK           RGB565CONVERT(0, 0, 0)
#define BRIGHTBLUE      RGB565CONVERT(0, 0, 255)
#define BRIGHTGREEN     RGB565CONVERT(0, 255, 0)
#define BRIGHTCYAN      RGB565CONVERT(0, 255, 255)
#define BRIGHTRED       RGB565CONVERT(255, 0, 0)
#define BRIGHTMAGENTA   RGB565CONVERT(255, 0, 255)
#define BRIGHTYELLOW    RGB565CONVERT(255, 255, 0)
#define BLUE            RGB565CONVERT(0, 0, 128)
#define GREEN           RGB565CONVERT(0, 128, 0)
#define CYAN            RGB565CONVERT(0, 128, 128)
#define RED             RGB565CONVERT(128, 0, 0)
#define MAGENTA         RGB565CONVERT(128, 0, 128)
#define BROWN           RGB565CONVERT(255, 128, 0)
#define LIGHTGRAY       RGB565CONVERT(128, 128, 128)
#define DARKGRAY        RGB565CONVERT(64, 64, 64)
#define LIGHTBLUE       RGB565CONVERT(128, 128, 255)
#define LIGHTGREEN      RGB565CONVERT(128, 255, 128)
#define LIGHTCYAN       RGB565CONVERT(128, 255, 255)
#define LIGHTRED        RGB565CONVERT(255, 128, 128)
#define LIGHTMAGENTA    RGB565CONVERT(255, 128, 255)
#define YELLOW          RGB565CONVERT(255, 255, 128)
#define WHITE           RGB565CONVERT(255, 255, 255)
#define GRAY0           RGB565CONVERT(224, 224, 224)
#define GRAY1           RGB565CONVERT(192, 192, 192)
#define GRAY2           RGB565CONVERT(160, 160, 160)
#define GRAY3           RGB565CONVERT(128, 128, 128)
#define GRAY4           RGB565CONVERT(96, 96, 96)
#define GRAY5           RGB565CONVERT(64, 64, 64)
#define GRAY6           RGB565CONVERT(32, 32, 32)


#endif
